import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;


public class ComputeCash {
	final private HashMap<Integer, Integer> cash;
	private Compute compute;
	ComputeCash(Compute compute) {
		this.cash = new HashMap<Integer, Integer>();
		this.compute = compute;
	}
	synchronized Integer compute(int arg, int n) {
		Integer result = cash.get(arg);
		if (result == null) {
			result = compute.compute(arg, n);
			cash.put(arg, result);
		}
		return result;
	}
	HashMap<Integer, Integer> getMap() {
		return cash;
	}
}
